<template>
  <div class="newsListWrap">
    <h3>新闻列表的内容</h3>

    <div id="handleBox">
      <el-form :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="">
          <el-input
            v-model="formInline.user"
            placeholder="请输入要搜索的内容"
          ></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" icon="el-icon-search" @click="onSubmit"
            >查询</el-button
          >
          <el-button type="primary" icon="el-icon-plus" @click="addShowDialog"
            >添加</el-button
          >
        </el-form-item>
      </el-form>
    </div>

    <div id="showTableBox">
      <el-table size="small" :data="tableData" border style="width: 100%">
        <el-table-column prop="date" label="日期"> </el-table-column>
        <el-table-column prop="title" label="标题"> </el-table-column>
        <el-table-column prop="author" label="作者"> </el-table-column>
        <el-table-column prop="author" label="操作">
          <template slot-scope="">
            <el-button type="primary" size="small" icon="el-icon-edit">
              编辑</el-button
            >
            <el-button type="danger" size="small" icon="el-icon-delete">
              删除</el-button
            >
          </template>
        </el-table-column>
      </el-table>
    </div>

    <div id="pageBox">
      <el-pagination background layout="prev, pager, next" :total="1000">
      </el-pagination>
    </div>

    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="50%"
      :before-close="handleClose"
    >
      <el-form ref="form" :model="form" label-width="80px">
      <el-form-item label="新闻标题">
        <el-input v-model="form.name"></el-input>
      </el-form-item>
  <el-form-item label="新闻作者">
        <el-input v-model="form.title"></el-input>
      </el-form-item>
      <el-form-item label="发布时间">
        <el-col :span="11">
          <el-date-picker
            type="date"
            placeholder="选择日期"
            v-model="form.date1"
            style="width: 100%"
          ></el-date-picker>
        </el-col>
       
      </el-form-item>
      <el-form-item label="是否下架">
        <el-switch v-model="form.delivery"></el-switch>
      </el-form-item>
     

      <el-form-item label="新闻内容">
        <el-input type="textarea" v-model="form.desc"></el-input>
      </el-form-item>

    </el-form>
    </el-dialog>

    
  </div>
</template>

<script>
export default {
  name: "newsList",
  data() {
    return {
      formInline: {
        user: "",
        region: "",
      },
      tableData: [
        {
          date: "2016-05-02",
          author: "央视新闻",
          title: "解读加快建设全国统一大市场",
        },
        {
          date: "2016-05-02",
          author: "央视新闻",
          title: "广州新增38例阳性感染者",
        },
        {
          date: "2016-05-02",
          author: "新华网",
          title: "安全生产十五条措施",
        },
        {
          date: "2016-05-02",
          author: "央视新闻",
          title: "官方辟谣东航飞机失事与副驾有关",
        },
      ],
      dialogVisible: false,
      form: {
          name: '',
          title:'',
          region: '',
          date1: '',
          
          delivery: false,
          type: [],
          resource: '',
          desc: ''
        }
    };
  },
  created() {
    console.log("新闻列表被创建了");
  },
  methods: {
    onSubmit() {
      console.log("submit!");
    },
    addShowDialog() {
      this.dialogVisible = true;
    },
  },
  mounted() {},
};
</script>

<style lang="scss" scoped>
.newsListWrap {
  padding: 20px;
  #pageBox {
    margin-top: 20px;
    text-align: center;
  }
}
</style>